cmake_minimum_required (VERSION 2.8) 

PROJECT(curl_with_mbedtls)

SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

IF(NOT MSVC)
  IF(WIN32)
    FIND_PACKAGE(CURL)
  ELSE()
    FIND_PACKAGE(CURL REQUIRED)
  ENDIF()
ENDIF()

IF(MSVC OR (WIN32 AND NOT CURL_FOUND))
  SET(CURL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/deps/curl/include" CACHE PATH "")
  SET(CURL_LIBRARIES curl CACHE STRING "")
  ADD_SUBDIRECTORY(mbedtls)
  SET_PROPERTY(TARGET mbedcrypto PROPERTY FOLDER "libs")
  SET_PROPERTY(TARGET mbedx509 PROPERTY FOLDER "libs")
  SET_PROPERTY(TARGET mbedtls PROPERTY FOLDER "libs")
  ADD_SUBDIRECTORY(curl)
  SET_PROPERTY(TARGET curl PROPERTY FOLDER "libs")
ELSE()
  SET(CURL_INCLUDE_DIRS "${CURL_INCLUDE_DIRS}" CACHE PATH "")
  SET(CURL_LIBRARIES "${CURL_LIBRARIES}" CACHE STRING "")
ENDIF()
